//首页 —— 属于有状态组件（是否显示登录密码）
import 'package:flutter/material.dart';
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
import 'package:http/http.dart';
import 'package:zhihuishequ/constants/api_constants.dart';
import 'package:zhihuishequ/constants/ui_constants.dart';
import 'package:zhihuishequ/widgets/Community.dart';
import 'package:zhihuishequ/widgets/mine.dart';
import 'package:zhihuishequ/widgets/property.dart';

import '../widgets/index.dart';

class HomePage extends StatefulWidget {
  HomePage({super.key});

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  int curIdx = 0;
  List tabs = [Index(), Property(), Community(), Mine()];

  @override
  initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    // var args = ModalRoute.of(context)!.settings.arguments as Map;
    //页面组件与普通组件不同点：根组件一般是Scaffold
    return Scaffold(
      //顶部状态栏
      appBar: AppBar(
        automaticallyImplyLeading: false, //隐藏左侧的后退按钮
        title: Text('首页'),
        // leading: Center(child: Text('返回')),
        actions: [
          InkWell(
            onTap: () {
              print('search...');
            },
            borderRadius: BorderRadius.circular(100),
            child: Padding(
              padding: EdgeInsets.all(5),
              child: Icon(Icons.search),
            ),
          ),
          InkWell(
            onTap: () {
              print('settings...');
            },
            borderRadius: BorderRadius.circular(100),
            child: Padding(
              padding: EdgeInsets.all(5),
              child: Icon(Icons.settings),
            ),
          ),
        ],
      ),
      //页面主体
      body: tabs[curIdx],
      //底部导航栏/页签栏
      bottomNavigationBar: BottomNavigationBar(
        type: BottomNavigationBarType.fixed,
        items: [
          BottomNavigationBarItem(icon: Icon(Icons.home), label: '首页'),
          BottomNavigationBarItem(icon: Icon(Icons.business), label: '物业'),
          BottomNavigationBarItem(icon: Icon(Icons.groups), label: '社区'),
          BottomNavigationBarItem(icon: Icon(Icons.person), label: '我的'),
        ],
        currentIndex: curIdx,
        backgroundColor: Color(0xFFFFFFFF),
        selectedItemColor: Color(0xFF009900),
        onTap: (i) => setState(() {
          curIdx = i;
        }),
      ),

      //右下角的悬浮按钮
      //左侧抽屉
      //右侧抽屉
    );
  }
}
